package hessian.client;   
  
import hessian.service.HessianService;

import java.net.MalformedURLException;
import java.util.HashMap;

import com.caucho.hessian.client.HessianProxyFactory;
  
/**  
 *  
 * @author absolute  
 */  
public class HessianClient {   
       
    private String url = "http://localhost:8080/HessianTest/test";   
       
    public HessianService getService() throws MalformedURLException {   
        HessianProxyFactory factory = new HessianProxyFactory();              
        return  (HessianService) factory.create(HessianService.class, url);   
    }   
       
    public static void main(String[] args) {   
        HessianClient client = new HessianClient();   
        try {   
            HessianService service = client.getService();   
            System.out.println(service.sayHello());   
            HashMap<String, String> map = new HashMap<String, String>();
            long tagTime  = System.currentTimeMillis();
            for (int i = 0; i < 100000; i++) {
				map.put("key"+i, "data"+i);
			}
            System.out.println("make data...." + (System.currentTimeMillis() - tagTime));
            tagTime  = System.currentTimeMillis();
            String s = service.doMessage(map);
            System.out.println("process data...." + s.length()+ " use:" + (System.currentTimeMillis() - tagTime));
            
        } catch (Exception e) {   
            e.printStackTrace();   
        }   
    }   
}   